<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="styleImageString">
              <j-image-upload isMultiple  v-model="model.styleImage" ></j-image-upload>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="款号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="codeNum">
              <a-input v-model="model.codeNum" placeholder="请输入款号" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="款类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="styleCate">
              <j-dict-select-tag type="list" v-model="model.styleCate" dictCode="style_type" placeholder="请选择款类" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="款式名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
              <a-input v-model="model.name" placeholder="请输入款式名称" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="胶膜号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="modelNum">
              <a-input v-model="model.modelNum" placeholder="请输入胶膜号" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="所属客户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="customer">
              <j-dict-select-tag type="list" v-model="model.customer" dictCode="customer_info,cus_name,cus_name" placeholder="请选择所属客户" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="头版金重" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goldWeight">
              <a-input-number v-model="model.goldWeight" placeholder="请输入头版金重" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="耗率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attritionRate">
              <a-input-number v-model="model.attritionRate" placeholder="请输入耗率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="工费" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="labourCost">
              <a-input-number v-model="model.labourCost" placeholder="请输入工费" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="规格/手寸" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="styleSize">
              <a-input v-model="model.styleSize" placeholder="请输入规格/手寸" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="长度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="length">
              <a-input-number v-model="model.length" placeholder="请输入长度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="宽度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="width">
              <a-input-number v-model="model.width" placeholder="请输入宽度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="银版重" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="silverModelWeight">
              <a-input-number v-model="model.silverModelWeight" placeholder="请输入银版重" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="蜡版重" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="waxModelWeight">
              <a-input-number v-model="model.waxModelWeight" placeholder="请输入蜡版重" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="难度级别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="difficultLevel">
                <j-dict-select-tag type="list" v-model="model.difficultLevel"  dictCode="difficult_level" placeholder="请选择难度级别" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unitPrice">
              <a-input-number v-model="model.unitPrice" placeholder="请输入单价" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="款式系列" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="styleSeries">
              <a-input v-model="model.styleSeries" placeholder="请输入款式系列" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="生产要求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionRequirement">
              <a-textarea v-model="model.productionRequirement" placeholder="请输入生产要求" ></a-textarea>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="起版要求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="platemakingRequirement">
              <a-textarea v-model="model.platemakingRequirement" placeholder="请输入起版要求" ></a-textarea>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="烤漆要求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paintRequirement">
              <a-textarea v-model="model.paintRequirement"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="电镀要求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="electroplateRequirement">
              <a-textarea v-model="model.electroplateRequirement"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="包装要求" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="packRequirement">
              <a-textarea v-model="model.packRequirement"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="编码标签" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="codeNumKey">
              <a-input v-model="model.codeNumKey" placeholder="请输入编码标签" disabled></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
      <!-- 子表单区域 -->
    <a-tabs v-model="activeKey" @change="handleChangeTabs">
      <a-tab-pane tab="配石资料" :key="refKeys[0]" :forceRender="true">
        <j-editable-table
          :ref="refKeys[0]"
          :loading="styleStoneInfoTable.loading"
          :columns="styleStoneInfoTable.columns"
          :dataSource="styleStoneInfoTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :actionButton="true"/>
      </a-tab-pane>
      <a-tab-pane tab="配件资料" :key="refKeys[1]" :forceRender="true">
        <j-editable-table
          :ref="refKeys[1]"
          :loading="styleAccessoryInfoTable.loading"
          :columns="styleAccessoryInfoTable.columns"
          :dataSource="styleAccessoryInfoTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :actionButton="true"/>
      </a-tab-pane>
      <a-tab-pane tab="工序资料" :key="refKeys[2]" :forceRender="true">
        <j-editable-table
          :ref="refKeys[2]"
          :loading="styleWorkingProcedureTable.loading"
          :columns="styleWorkingProcedureTable.columns"
          :dataSource="styleWorkingProcedureTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :actionButton="true"/>
      </a-tab-pane>
      <a-tab-pane tab="电镀资料" :key="refKeys[3]" :forceRender="true">
        <j-editable-table
          :ref="refKeys[3]"
          :loading="styleElectroplateInfoTable.loading"
          :columns="styleElectroplateInfoTable.columns"
          :dataSource="styleElectroplateInfoTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :actionButton="true"/>
      </a-tab-pane>
      <a-tab-pane tab="套件资料" :key="refKeys[4]" :forceRender="true">
        <j-editable-table
          :ref="refKeys[4]"
          :loading="styleSuitInfoTable.loading"
          :columns="styleSuitInfoTable.columns"
          :dataSource="styleSuitInfoTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :actionButton="true"/>
      </a-tab-pane>
      <a-tab-pane tab="其他资料" :key="refKeys[5]" :forceRender="true">
        <j-editable-table
          :ref="refKeys[5]"
          :loading="styleOtherInfoTable.loading"
          :columns="styleOtherInfoTable.columns"
          :dataSource="styleOtherInfoTable.dataSource"
          :maxHeight="300"
          :disabled="formDisabled"
          :rowNumber="true"
          :rowSelection="true"
          :actionButton="true"/>
      </a-tab-pane>
    </a-tabs>
  </a-spin>
</template>

<script>

  import { getAction } from '@/api/manage'
  import { FormTypes,getRefPromise,VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'
  import { JEditableTableModelMixin } from '@/mixins/JEditableTableModelMixin'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'StyleInfoForm',
    mixins: [JEditableTableModelMixin],
    components: {
    },
    data() {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        labelCol2: {
          xs: { span: 24 },
          sm: { span: 3 },
        },
        wrapperCol2: {
          xs: { span: 24 },
          sm: { span: 20 },
        },
        model:{
            codeNumKey:"style_code",
        },
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 1,
        validatorRules: {
           name: [
              { required: true, message: '请输入名称!'},
           ],
        },
        refKeys: ['styleStoneInfo', 'styleAccessoryInfo', 'styleWorkingProcedure', 'styleElectroplateInfo', 'styleSuitInfo', 'styleOtherInfo', ],
        tableKeys:['styleStoneInfo', 'styleAccessoryInfo', 'styleWorkingProcedure', 'styleElectroplateInfo', 'styleSuitInfo', 'styleOtherInfo', ],
        activeKey: 'styleStoneInfo',
        // 配石资料
        styleStoneInfoTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '石号',
              key: 'codeNum',
              type: FormTypes.popup,
              popupCode:"stone_style_report",
              destFields:"codeNum,cateName,shape,name,level,cutting,color,sizeNum,unitWeight,stoneUnitPrice",
              orgFields:"stone_code_num,cate_id,shape,name,level,cutting,color,size_num,weight,price",
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
              validateRules: [{ required: true, message: '${title}不能为空' }],
            },
            {
              title: '石号名称',
              key: 'name',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '石类',
              key: 'cateName',
              type: FormTypes.select,
              dictCode:"stone_category,cate_name,cate_name",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '形状',
              key: 'shape',
              type: FormTypes.select,
              dictCode:"shape",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '筛号',
              key: 'sizeNum',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '镶法',
              key: 'inlay',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '石数',
              key: 'stoneCount',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单粒石重',
              key: 'unitWeight',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '石重',
              key: 'weight',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:"unit_weight",
            },
            {
              title: '镶工单价',
              key: 'inlayUnitCost',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '镶工价',
              key: 'inlayCost',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '镶工总价',
              key: 'inlayTotalCost',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '石单价',
              key: 'stoneUnitPrice',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '石总价',
              key: 'stoneTotalPrice',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '颜色',
              key: 'color',
              type: FormTypes.select,
              dictCode:"color",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '车工',
              key: 'cutting',
              type: FormTypes.select,
              dictCode:"cutting",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '配石方案',
              key: 'combination',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '级别',
              key: 'level',
              type: FormTypes.select,
              dictCode:"stone_level",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '主副石',
              key: 'mainStone',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '客来石',
              key: 'comeFrom',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },

            {
              title: 'code_num',
              key: 'code_num',
              type:"hidden"
            },

            {
              title: 'cate_name',
              key: 'cate_name',
              type:"hidden"
            },






            {
              title: 'size_num',
              key: 'size_num',
              type:"hidden"
            },

            {
              title: 'unit_weight',
              key: 'unit_weight',
              type:"hidden"
            },

            {
              title: 'stone_unit_price',
              key: 'stone_unit_price',
              type:"hidden"
            },
          ]
        },
        // 配件资料
        styleAccessoryInfoTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '配件编码',
              key: 'accessoryNum',
              type: FormTypes.popup,
              popupCode:"accessory_info_report",
              destFields:"accessoryNum,name,style,cateName,countWeightPattern,unitPrice,unitWeight,countPricePattern,per,karat,attribute",
              orgFields:"code_num,name,style,cate_name,count_weight_pattern,price,weight,count_price_pattern,per,karat,attribute",
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '配件名称',
              key: 'name',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '规格',
              key: 'style',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '类别',
              key: 'cateName',
              type: FormTypes.select,
              dictCode:"accessory_category,cate_name,cate_name",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '数量',
              key: 'count',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '计重方式',
              key: 'countWeightPattern',
              type: FormTypes.select,
              dictCode:"count_weight_pattern",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: ' 计耗',
              key: 'isAttrition',
              type: FormTypes.checkbox,
              customValue: ['Y', 'N'],
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单价',
              key: 'unitPrice',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '总工价',
              key: 'labourTotalCost',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单重',
              key: 'unitWeight',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '总重',
              key: 'totalWeight',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '计价方式',
              key: 'countPricePattern',
              type: FormTypes.select,
              dictCode:"count_price_pattern",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单位',
              key: 'per',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '成色',
              key: 'karat',
              type: FormTypes.select,
              dictCode:"",
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '属性',
              key: 'attribute',
              type: FormTypes.input,
              disabled:true,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '款式ID',
              key: 'styleInfoId',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },

            {
              title: 'accessory_num',
              key: 'accessory_num',
              type:"hidden"
            },



            {
              title: 'cate_name',
              key: 'cate_name',
              type:"hidden"
            },

            {
              title: 'count_weight_pattern',
              key: 'count_weight_pattern',
              type:"hidden"
            },

            {
              title: 'unit_price',
              key: 'unit_price',
              type:"hidden"
            },

            {
              title: 'unit_weight',
              key: 'unit_weight',
              type:"hidden"
            },

            {
              title: 'count_price_pattern',
              key: 'count_price_pattern',
              type:"hidden"
            },



          ]
        },
        // 工序资料
        styleWorkingProcedureTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '序号',
              key: 'orderIndex',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '工序',
              key: 'name',
              type: FormTypes.popup,
              popupCode:"working_procedure_info_report",
              destFields:"name,dept,difficultLevel,labourCostInward,labourCostOutward,attritionRate,manHour,requirement,labourCostOutwork,labourUnitCost,remark",
              orgFields:"name,dept,difficult_level,labour_cost_inward,labour_cost_outward,attrition_rate,man_hour,requirement,labour_cost_outwork,labour_unit_cost,remark",
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '执行部门',
              key: 'dept',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '难度级别',
              key: 'difficultLevel',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '对内工价',
              key: 'labourCostInward',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '对外工价',
              key: 'labourCostOutward',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '耗率',
              key: 'attritionRate',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '工时',
              key: 'manHour',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '要求',
              key: 'requirement',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '外发工价',
              key: 'labourCostOutwork',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单件工费',
              key: 'labourUnitCost',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },



            {
              title: 'difficult_level',
              key: 'difficult_level',
              type:"hidden"
            },

            {
              title: 'labour_cost_inward',
              key: 'labour_cost_inward',
              type:"hidden"
            },

            {
              title: 'labour_cost_outward',
              key: 'labour_cost_outward',
              type:"hidden"
            },

            {
              title: 'attrition_rate',
              key: 'attrition_rate',
              type:"hidden"
            },

            {
              title: 'man_hour',
              key: 'man_hour',
              type:"hidden"
            },


            {
              title: 'labour_cost_outwork',
              key: 'labour_cost_outwork',
              type:"hidden"
            },

            {
              title: 'labour_unit_cost',
              key: 'labour_unit_cost',
              type:"hidden"
            },

          ]
        },
        // 电镀资料
        styleElectroplateInfoTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '电镀名称',
              key: 'name',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '密度',
              key: 'density',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '厚度',
              key: 'thickness',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '面积',
              key: 'acreage',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单价',
              key: 'unitPrice',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '金额',
              key: 'amount',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '按件计价',
              key: 'countPricePattern',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        // 套件资料
        styleSuitInfoTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '套件编码',
              key: 'suitNum',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '数量',
              key: 'count',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        // 其他资料
        styleOtherInfoTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '项目名称',
              key: 'name',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '单价',
              key: 'unitPrice',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '数量',
              key: 'count',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '金额',
              key: 'amount',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
            {
              title: '备注',
              key: 'remark',
              type: FormTypes.input,
              width:"200px",
              placeholder: '请输入${title}',
              defaultValue:'',
            },
          ]
        },
        url: {
          add: "/styleInfo/styleInfo/add",
          edit: "/styleInfo/styleInfo/edit",
          queryById: "/styleInfo/styleInfo/queryById",
          styleStoneInfo: {
            list: '/styleInfo/styleInfo/queryStyleStoneInfoByMainId'
          },
          styleAccessoryInfo: {
            list: '/styleInfo/styleInfo/queryStyleAccessoryInfoByMainId'
          },
          styleWorkingProcedure: {
            list: '/styleInfo/styleInfo/queryStyleWorkingProcedureByMainId'
          },
          styleElectroplateInfo: {
            list: '/styleInfo/styleInfo/queryStyleElectroplateInfoByMainId'
          },
          styleSuitInfo: {
            list: '/styleInfo/styleInfo/queryStyleSuitInfoByMainId'
          },
          styleOtherInfo: {
            list: '/styleInfo/styleInfo/queryStyleOtherInfoByMainId'
          },
        }
      }
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
    },
    methods: {
      addBefore(){
        this.styleStoneInfoTable.dataSource=[]
        this.styleAccessoryInfoTable.dataSource=[]
        this.styleWorkingProcedureTable.dataSource=[]
        this.styleElectroplateInfoTable.dataSource=[]
        this.styleSuitInfoTable.dataSource=[]
        this.styleOtherInfoTable.dataSource=[]
      },
      getAllTable() {
        let values = this.tableKeys.map(key => getRefPromise(this, key))
        return Promise.all(values)
      },
      /** 调用完edit()方法之后会自动调用此方法 */
      editAfter() {
        this.$nextTick(() => {
        })
        // 加载子表数据
        if (this.model.id) {
          let params = { id: this.model.id }
          this.requestSubTableData(this.url.styleStoneInfo.list, params, this.styleStoneInfoTable)
          this.requestSubTableData(this.url.styleAccessoryInfo.list, params, this.styleAccessoryInfoTable)
          this.requestSubTableData(this.url.styleWorkingProcedure.list, params, this.styleWorkingProcedureTable)
          this.requestSubTableData(this.url.styleElectroplateInfo.list, params, this.styleElectroplateInfoTable)
          this.requestSubTableData(this.url.styleSuitInfo.list, params, this.styleSuitInfoTable)
          this.requestSubTableData(this.url.styleOtherInfo.list, params, this.styleOtherInfoTable)
        }
      },
      //校验所有一对一子表表单
      validateSubForm(allValues){
          return new Promise((resolve,reject)=>{
            Promise.all([
            ]).then(() => {
              resolve(allValues)
            }).catch(e => {
              if (e.error === VALIDATE_NO_PASSED) {
                // 如果有未通过表单验证的子表，就自动跳转到它所在的tab
                this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
              } else {
                console.error(e)
              }
            })
          })
      },
      /** 整理成formData */
      classifyIntoFormData(allValues) {
        let main = Object.assign(this.model, allValues.formValue)
        return {
          ...main, // 展开
          styleStoneInfoList: allValues.tablesValue[0].values,
          styleAccessoryInfoList: allValues.tablesValue[1].values,
          styleWorkingProcedureList: allValues.tablesValue[2].values,
          styleElectroplateInfoList: allValues.tablesValue[3].values,
          styleSuitInfoList: allValues.tablesValue[4].values,
          styleOtherInfoList: allValues.tablesValue[5].values,
        }
      },
      validateError(msg){
        this.$message.error(msg)
      },

    }
  }
</script>

<style scoped>
</style>